package com.itcast.service.Impl;

import com.itcast.dao.Impl.StudentDaoImpl;
import com.itcast.dao.StudentDao;
import com.itcast.domain.PageBean;
import com.itcast.domain.Student;
import com.itcast.service.StudentService;

import java.util.ArrayList;
import java.util.List;

/**
 * @param
 * @return
 */
public class StudentServiceImpl implements StudentService {
    //创建持久层对象，复用
    StudentDao dao=new StudentDaoImpl();
    @Override
    public List<Student> findAll() {
        //定义返回值
        List<Student> list = new ArrayList<>();
        //调用持久层方法
        list=dao.findAll();
        return list;
    }

    @Override
    public int add(Student student) {
        //定义返回值
        int i=0;
        i=dao.add(student);
        return i;
    }

    @Override
    public Student findById(int i) {
        //定义返回值
        Student student = new Student();
        //调用持久层方法
        student =dao.findById(i);
        return student;
    }

    @Override
    public int delete(int id) {
        //定义返回值
        int i=0;
        //调用持久层的删除方法
        i= dao.delete(id);
        return i;
    }

    @Override
    public int update(Student student) {
        //定义返回值
        int i=0;
        //调用持久层的删除方法
        i= dao.update(student);
        return i;
    }

    @Override
    public PageBean<Student> findByPage(int currentPage, int rows) {
        //定义返回值
        PageBean<Student> pageBean = new PageBean<>();
        //调用持久层方法
        pageBean = dao.findByPage(currentPage,rows);
        return pageBean;
    }

    @Override
    public boolean login(String username, String password) {
        //定义返回值
        boolean flag=false;
        //调用持久层登录方法
        flag=dao.login(username,password);
        return flag;
    }
}
